package service

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"hello-kratos/kratos-client/api/v1"
	"hello-kratos/kratos-client/internal/biz"
)

type UserService struct {
	v1.UserHTTPServer
	l  *log.Helper
	uc *biz.UserUseCase
}

func NewUserService(logger log.Logger, uc *biz.UserUseCase) *UserService {
	return &UserService{
		l:  log.NewHelper(logger),
		uc: uc,
	}
}

func (s *UserService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.LoginResponse, error) {
	if err := s.uc.Login(ctx, req); err != nil {
		return nil, err
	}
	return &v1.LoginResponse{
		Code: 0,
		Msg:  "login success",
	}, nil
}
